<template>
  <div class="login">
    <div class="left">
      <div class="top">
        <img class="login-logo" src="" alt="" />
        <span class="t1">黑马面面</span>
        <div class="line"></div>
        <span class="t2">用户登录</span>
      </div>

      <!-- 表单 -->
      <el-form :model="form" class="form" :rules="rules" ref="form">
        <!-- 手机号输入框 -->
        <el-form-item prop="phone">
          <el-input
            prefix-icon="el-icon-user"
            v-model="form.phone"
            placeholder="请输入手机号"
          ></el-input>
        </el-form-item>
        <!-- 密码输入框 -->
        <el-form-item prop="password">
          <el-input
            show-password
            prefix-icon="el-icon-lock"
            v-model="form.password"
            placeholder="请输入密码"
          ></el-input>
        </el-form-item>
        <!-- 验证码输入框 -->
        <el-form-item prop="code">
          <el-row>
            <el-col :span="16">
              <el-input
                prefix-icon="el-icon-key"
                v-model="form.code"
                placeholder="请输入验证码"
              >
              </el-input>
            </el-col>
            <el-col :span="8">
              <img class="code" src="" alt="" />
            </el-col>
          </el-row>
        </el-form-item>
        <!-- 用户协议多选框 -->
        <el-form-item prop="isPass">
          <el-checkbox v-model="form.isPass">
            我已阅读并同意<el-link type="primary">用户协议</el-link>和<el-link
              type="primary"
              >隐私条款</el-link
            >
          </el-checkbox>
        </el-form-item>
        <!-- 登录按钮 -->
        <el-form-item>
          <el-button class="btn" type="primary" @click="toLogin"
            >登录</el-button
          >
          <!-- el-button的兄弟标签默认样式有间距，添加br换行可以取消默认样式 -->
          <br />
          <el-button class="btn" type="primary">注册</el-button>
        </el-form-item>
      </el-form>
    </div>
    <img src="" class="right" alt="" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        phone: "",
        password: "",
        code: "",
        isPass: false,
      },

      rules: {
        phone: [{ required: true, message: "请输入手机号", trigger: "change" }],
        password: [
          { required: true, message: "请输入密码", trigger: "change" },
          { min: 6, max: 12, message: "请输入6-12位密码！", trigger: "change" },
        ],
        code: [
          { required: true, message: "请输入验证码", trigger: "change" },
          { min: 4, max: 4, message: "请输入验证码", trigger: "change" },
        ],
        isPass: [{ required: true, message: "请勾选协议", trigger: "change" }],
      },
    };
  },
  methods: {
    toLogin() {
      this.$refs.form.validate((result) => {
        if (result) {
          this.$message.success("登录成功");
        } else {
          this.$message.error("登录失败");
        }
      });
    },
  },
};
</script>

<style lang="less">
.login {
  width: 100%;
  height: 100%;
  background: linear-gradient(#1493fa 28%, #01c6fa 96%);
  display: flex;
  justify-content: space-around;
  align-items: center;
  .left {
    width: 478px;
    height: 550px;
    padding: 42px;
    background-color: #f5f5f5;
    .top {
      display: flex;
      align-items: center;
      .login-logo {
        width: 22px;
        height: 17px;
      }
      .t1 {
        font-size: 24px;
        font-weight: 400;
        text-align: left;
        color: #0c0c0c;
        margin: 0 15px;
      }
      .line {
        width: 1px;
        height: 28px;
        background: #c7c7c7;
      }
      .t2 {
        font-size: 22px;
        font-weight: 400;
        text-align: left;
        color: #0c0c0c;
        margin-left: 15px;
      }
    }
    .code {
      width: 100%;
      height: 40px;
    }
    .form {
      margin-top: 30px;
    }
    .btn {
      display: block;
      width: 100%;
    }
  }
}
</style>